package com.flying.invest.job;

import com.flying.common.util.Codes;
import com.flying.framework.annotation.Service;
import com.flying.framework.model.ActionResult;
import com.flying.framework.model.ModelFactory;
import com.flying.framework.service.AbstractService;
import com.flying.invest.account.service.AccountService;

@Service(value="AccountJob", desc="")
public class AccountJob extends AbstractService {
	private AccountService accountService;
	
	public void setAccountService(AccountService s) {
		this.accountService = s;
	}
	
	private Long[] getUserIds() {
		String suid = this.getServiceConfig().getConfig("user_ids");
		String[] uids = suid.split(",");
		Long[] ls = new Long[uids.length];
		for(int i=0; i< uids.length; i++) {
			ls[i] = Long.parseLong(uids[i]);
		}
		return ls;
	}
	public ActionResult run() {
		for(Long user_id: getUserIds()) {
			this.accountService.updateNetValueByUserId(user_id);
		}
		return ModelFactory.create(ActionResult.class, Codes.CODE, Codes.SUCCESS);
	}
}
